		            $dg.datagrid("updateRow",{
		            	index : index ,
		            	row : todown
		            });
		            $dg.datagrid("updateRow",{
		            	index : index -1 ,
		            	row : toup
		            });	
		            
		            
		            $dg.datagrid("updateRow",{
		            	index : index + 1,
		            	row : todown
		            });
		            $dg.datagrid("updateRow",{
		            	index : index ,
		            	row : toup
		            });	
		            
		            
			checkOnSelect	: false,


ag_$entityfield_table.datagrid('checkRow', index);

ag_$pagefield_table.datagrid('checkRow', index);




,
			onCheck			: function(index, row){
				var checked_row=ag_$entityfield_table.datagrid('getSelected');
				var checked_index=ag_$entityfield_table.datagrid('getRowIndex',checked_row);
				ag_checked_index = index;
				if(checked_index != index){
					ag_$entityfield_table.datagrid('checkRow', index);
				}
			}

,
			onCheck			: function(index, row){
				var checked_row=ag_$pagefield_table.datagrid('getSelected');
				var checked_index=ag_$pagefield_table.datagrid('getRowIndex',checked_row);
				ag_checked_index = index;
				if(checked_index != index){
					ag_$pagefield_table.datagrid('checkRow', index);
				}
			}
		            
		            
		function columnLabelOnChange(newValue, oldValue){
            var row = ag_$entityfield_table.datagrid('getSelected');  
            var rindex = ag_$entityfield_table.datagrid('getRowIndex', row);  
            var editor = ag_$entityfield_table.datagrid('getEditor', {  
                    index : rindex,  
                    field : 'comments'  
                }); 

            if(editor && editor.target)
            	$(editor.target).textbox("setValue",newValue);
		}	
		
function keepFieldInfoSame(title,index){
	if(title == "实体字段")
		return ;
	var entity_fields = ag_$entityfield_table.datagrid("getRows");
	var page_fields = ag_$pagefield_table.datagrid("getRows");
	var changes = 0;	
	for(var i=0; i < entity_fields.length;i++){
		ag_$entityfield_table.datagrid("endEdit",i);
		if(page_fields[i].entityField.columnName != entity_fields[i].columnName
				|| page_fields[i].entityField.attrName != entity_fields[i].attrName){
			page_fields[i].entityField.columnName = entity_fields[i].columnName;
			page_fields[i].entityField.attrName = entity_fields[i].attrName;
			changes += 1;			
		}
		ag_$entityfield_table.datagrid("beginEdit",i);
	}
	if(changes){
		console.log(page_fields.length)
		var load_data = {"data":{"total":page_fields.length, "rows" : page_fields}};	
		ag_$pagefield_table.datagrid("loadData",load_data);
	}
}			            
		
		
function keepFieldInfoSame(title,index){

	if(title == "实体字段"){
		flashData(ag_$pagefield_table);
		return ;
	}

	if(title == "页面字段"){
		flashData(ag_$entityfield_table);
	}
	
	var entity_fields = ag_$entityfield_table.datagrid("getRows");	
	var page_fields = ag_$pagefield_table.datagrid("getRows");
	var changes = 0;	
	for(var i=0; i < entity_fields.length;i++){		
		if(page_fields[i].entityField.columnName != entity_fields[i].columnName
				|| page_fields[i].entityField.attrName != entity_fields[i].attrName){
			page_fields[i].entityField.columnName = entity_fields[i].columnName;
			page_fields[i].entityField.attrName = entity_fields[i].attrName;
			changes += 1;			
		}
	}
	if(changes){
		console.log(page_fields.length)
		var load_data = {"data":{"total":page_fields.length, "rows" : page_fields}};	
		ag_$pagefield_table.datagrid("loadData",load_data);
	}
}	


function flashData($dg){
	var rows=$dg.datagrid("getRows");
	for(var i=0; i < rows.length;i++){
		$dg.datagrid("endEdit",i);
		$dg.datagrid("beginEdit",i);
	}
}            